package com.tudouji.project.flow.service.impl;

import com.tudouji.project.flow.domain.BasePojo;
import com.tudouji.project.flow.mapper.BasePojoMapper;
import com.tudouji.project.flow.service.BasePojoService;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class BasePojoServiceImpl implements BasePojoService {

    @Autowired
    private BasePojoMapper pojoMapper;

    @Override
    public Integer getCounts(BasePojo base) throws Exception {
        String sql="SELECT COUNT(*) FROM "+base.getClassName() +" where guid=\'"+base.getGuid()+"\' and " +base.getCondition();
        Map<String, String> map=new HashMap<>();
        map.put("sql", sql);

        return this.pojoMapper.getCounts(map);
    }
}
